import math

def pylog(a,b):
    return math.log(b,a)
def pysin(a):
    return math.sin(math.radians(a))
def pycos(a):
    return math.cos(math.radians(a))
def sum(a,b):
    return (a+b)

def sub(a,b):
    return (a-b)

def multi(a,b):
    return (a*b)
def div(a,b):
    if b == 0:
        print("Division error")
        return b
    else:return (a/b)
def pycomplex(a,b):
    complexoperator = input("请输入复数的运算：+ - * /")
    if complexoperator == "+":
        print("a+b =  ",a+b)
        return a+b
    elif complexoperator == "-":
        print("a-b =  ", a-b)
        return a-b
    elif complexoperator == "*":
        print("a*b =  ", a*b)
        return a*b
    elif complexoperator == "/":
        print("a/b =  ", a/b)
        return a/b
    else: print("输入有误")

print("=================欢迎使用BESTI计算器===================")
print("||              作者： 20232304冯天悦               ||")
print("||              开发时间: 2024.3.27                ||")
print("||           Copyright(c) 2024 by BESTI          ||")
print("====================================================")
flag = True
while flag:
    a = eval(input("请输入a："))
    b = eval(input("请输入b："))

    operator = input("请输入运算符（+ - * / sin cos com log）")
    if operator == "+":
        print("a+b =",sum(a,b))
    elif operator == "-":
        print("a-b =",sub(a,b))
    elif operator == "*":
        print("a*b =",multi(a,b))
    elif operator == "/":
        print("a/b =",div(a,b))
    elif operator == "sin":
        print("sin(a) =",pysin(a))
        print("sin(b) =",pysin(b))
    elif operator == "cos":
        print("cos(a) =",pycos(a))
        print("cos(b) =",pycos(b))
    elif operator == "com":
        pycomplex(a,b)
    elif operator == "log":
        print("log a b =  ",pylog(a,b))
    else:
        print("无效的选择.")
        continue
    flag = False if input("是否要继续？Y/N ") == "n"  else True